package com.wnxy.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnxy.admin.dto.CarDto;
import com.wnxy.admin.entity.Transaction;
import com.wnxy.admin.mapper.TransactionMapper;
import com.wnxy.admin.service.ITransactionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 交易流水表 服务实现类
 * </p>
 *
 * @author All
 * @since 2023-11-29
 */
@Service
public class TransactionServiceImpl extends ServiceImpl<TransactionMapper, Transaction> implements ITransactionService {

    private final TransactionMapper transactionMapper;
    public TransactionServiceImpl(TransactionMapper transactionMapper){
        this.transactionMapper = transactionMapper;
    }

    @Override
    public PageInfo<Transaction> getAll(Integer pageNum, Integer pageSize, Long keyword) {
        PageHelper.startPage(pageNum, pageSize);

        QueryWrapper<Transaction> wrapper = new QueryWrapper<>();

        if (keyword != null) {
            wrapper.like("transaction_id", keyword);
        }

        List<Transaction> transactions = transactionMapper.selectList(wrapper);
        return new PageInfo<>(transactions);
    }
}
